#!/bin/sh

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)

echo "getting sources..."
  if [ ! -d linux-amlogic.git ]; then
    git clone https://github.com/codesnake/linux linux-amlogic.git
  fi

  cd linux-amlogic.git
    git pull
    GIT_REV=`git log -n1 --format=%H`
  cd ..

echo "copying sources..."
  rm -rf linux-amlogic-3.10-$GIT_REV
  cp -R linux-amlogic.git linux-amlogic-3.10-$GIT_REV

echo "cleaning sources..."
  rm -rf linux-amlogic-3.10-$GIT_REV/.git

echo "packing sources..."
  tar cvJf linux-amlogic-3.10-$GIT_REV.tar.xz linux-amlogic-3.10-$GIT_REV

echo "remove temporary sourcedir..."
  rm -rf linux-amlogic-3.10-$GIT_REV
